﻿/*--------------------------------------------------------------
 * Author : Shine K Velayudhan 
 ---------------------------------------------------------------*/
using System;

namespace IQN.Logging
{
    public class LogManager
    {
        private static LoggerRepository theLoggerTree = null;
        private static readonly object treeCreationLock = new object();

        public static ILogger GetLogger(Type sourceType)
        {
            if (null == sourceType)
            {
                throw new ArgumentException("sourceType can't be null.");
            }
            return TheLoggerTree.GetLogger(sourceType.Namespace);
        }

        internal static LoggerRepository TheLoggerTree
        {
            get
            {
                if (null == theLoggerTree)
                {
                    lock (treeCreationLock)
                    {
                        if (null == theLoggerTree)
                        {
                            theLoggerTree = new LoggerRepository();
                        }
                    }
                }
                return theLoggerTree;
            }
        }
    }
}
